package com.zhangjian.test;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Solution {
    public int sort (String inData) {
        String[] string  = inData.split(" ");
        int[] result = new int[string.length];
        Map<Integer,Integer> map  = new HashMap<Integer, Integer>();
        for (int i = 0; i < result.length ; i++) {
            result[i] = Integer.parseInt(string[i]);
            map.put(Integer.parseInt(string[i]),i);
        }
        Arrays.sort(result);
        int index = map.size();
        int count =  0 ;
        for (int i = 0; i < index - 1; i++) {
            if (map.get(result[i]) > map.get(result[i + 1])){
                map.put(result[i],i);
                count++ ;
            }
        }
        for (int i = 0; i <index - 1 ; i++) {
            System.out.print(map.get(result[i]) +" ");
        }
        System.out.println();
        return  count;
    }

    public static void main(String[] args) {
        Solution  solution = new Solution();
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        int result = solution.sort(str);
        System.out.println(result);
    }
}
